/*
 * Created by JFormDesigner on Tue Aug 07 22:41:13 CEST 2007
 */

package info.rflow.preferences;

import info.rflow.Utils;

import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.util.ResourceBundle;


/**
 * @author Holger Brandl
 */
public class ScriptParserSettings extends AbstractSettingsPanel {

    public static final String REGEX_BLOCK = "parser.regex.block";
    public static final String REGEX_BLOCK_DEFAULT = "foobar";


    public ScriptParserSettings() {
        initComponents();
    }


    void resetPanelSettings() {
        Utils.getPrefs().remove(REGEX_BLOCK);

        loadDefaults();
    }


    void applySettingsChanges() {
        Utils.getPrefs().put(REGEX_BLOCK, blockStartRegexField.getText());
    }


    protected void loadDefaults() {
        blockStartRegexField.setText(Utils.getPrefs().get(REGEX_BLOCK, REGEX_BLOCK_DEFAULT));
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner non-commercial license
        ResourceBundle bundle = ResourceBundle.getBundle("info.rflow.translation");
        panel2 = new JPanel();
        label1 = new JLabel();
        blockStartRegexField = new JTextField();
        label2 = new JLabel();
        outputRegexField = new JTextField();
        label3 = new JLabel();
        inputRegexField = new JTextField();
        schedulePanel = new JPanel();
        label4 = new JLabel();
        inputRegexField2 = new JTextField();

        //======== this ========
        setLayout(new GridBagLayout());
        ((GridBagLayout) getLayout()).columnWidths = new int[]{0, 0};
        ((GridBagLayout) getLayout()).rowHeights = new int[]{0, 0, 0};
        ((GridBagLayout) getLayout()).columnWeights = new double[]{1.0, 1.0E-4};
        ((GridBagLayout) getLayout()).rowWeights = new double[]{0.0, 0.0, 1.0E-4};

        //======== panel2 ========
        {
            panel2.setBorder(new CompoundBorder(
                    new TitledBorder(null, bundle.getString("GlobLearnSettings.panel2.border"), TitledBorder.LEADING, TitledBorder.TOP),
                    new EmptyBorder(5, 5, 5, 5)));
            panel2.setLayout(new GridBagLayout());
            ((GridBagLayout) panel2.getLayout()).columnWidths = new int[]{176, 15, 27, 0};
            ((GridBagLayout) panel2.getLayout()).rowHeights = new int[]{0, 0, 0, 0};
            ((GridBagLayout) panel2.getLayout()).columnWeights = new double[]{0.0, 0.0, 1.0, 1.0E-4};
            ((GridBagLayout) panel2.getLayout()).rowWeights = new double[]{0.0, 0.0, 0.0, 1.0E-4};

            //---- label1 ----
            label1.setText(bundle.getString("GlobLearnSettings.label1.text"));
            panel2.add(label1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));
            panel2.add(blockStartRegexField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0), 0, 0));

            //---- label2 ----
            label2.setText(bundle.getString("GlobLearnSettings.label2.text"));
            panel2.add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));
            panel2.add(outputRegexField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0), 0, 0));

            //---- label3 ----
            label3.setText(bundle.getString("GlobLearnSettings.label3.text"));
            panel2.add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            panel2.add(inputRegexField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0), 0, 0));
        }
        add(panel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));

        //======== schedulePanel ========
        {
            schedulePanel.setBorder(new CompoundBorder(
                    new TitledBorder(null, bundle.getString("GlobLearnSettings.schedulePanel.border"), TitledBorder.LEADING, TitledBorder.TOP),
                    new EmptyBorder(5, 5, 5, 5)));
            schedulePanel.setLayout(new GridBagLayout());
            ((GridBagLayout) schedulePanel.getLayout()).columnWidths = new int[]{0, 15, 0, 0};
            ((GridBagLayout) schedulePanel.getLayout()).rowHeights = new int[]{0, 0};
            ((GridBagLayout) schedulePanel.getLayout()).columnWeights = new double[]{0.0, 0.0, 1.0, 1.0E-4};
            ((GridBagLayout) schedulePanel.getLayout()).rowWeights = new double[]{0.0, 1.0E-4};

            //---- label4 ----
            label4.setText(bundle.getString("GlobLearnSettings.label4.text"));
            schedulePanel.add(label4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            schedulePanel.add(inputRegexField2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0), 0, 0));
        }
        add(schedulePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 0, 0), 0, 0));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
        loadDefaults();
    }


    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner non-commercial license
    private JPanel panel2;
    private JLabel label1;
    private JTextField blockStartRegexField;
    private JLabel label2;
    private JTextField outputRegexField;
    private JLabel label3;
    private JTextField inputRegexField;
    private JPanel schedulePanel;
    private JLabel label4;
    private JTextField inputRegexField2;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
